package com.link.base.base.contract.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.link.core.basic.annotations.JsonParam;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.link.base.base.contract.model.ModReceivable;
import com.link.base.base.contract.service.ModReceivableService;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.service.BasicService;
import com.link.core.basic.service.KeyGenerateService;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * 模具回款
 *
 * @author 王昊
 * @date 2021-03-18 15:54:57
 */
@Controller
@RequestMapping("/link/modReceivable")
public class ModReceivableController extends BasicController<ModReceivable> {

    @Resource
    private KeyGenerateService keyGenerateService;

    @Resource
    private ModReceivableService modReceivableService;

    @Override
    public BasicService<ModReceivable> getBasicService() throws Exception {
        return modReceivableService;
    }


    /**
     * 模具回款审批
     * @author 王昊
     * @date 9:12 2021/3/22
     * @param  entity, session, request
     **/
    @RequestMapping(value = "/modReceiveSubmit" , method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> modReceiveSubmit(@JsonParam ModReceivable entity, HttpSession session, HttpServletRequest request) {
        Map<String,Object> result = new HashMap<>(4);
        try {
            modReceivableService.modReceiveSubmit(entity);
            result.put("newRow",entity);
            result.put("success",true);
        } catch (Exception e) {
            result.put("success",false);
            result.put("result", e.getMessage());
        }
        return result;
    }


}
